package com.huawei.java.pojo;

/**
 * 服务器类型类
 * @author 金昊霖
 */
public final class ServerType implements Comparable<ServerType>{
    /**
     * 服务器名称
     */
    private final String name;
    /**
     * 处理器内核数
     */
    private final int cores;
    /**
     * 内存
     */
    private final int memory;
    /**
     * 硬件成本
     */
    private final int cost;
    /**
     * 能耗
     */
    private final int consumption;

    /**
     * 该服务器内核内存比
     */
    private final double ratio;

    private int performance;


    public int getPerformance() {
        return performance;
    }

    public void updatePerformance(int n){
        performance=cost+consumption*n;
    }
    /**
     * 根据输入的数据返回对应实例
     * @param strings 如[NV603, 92, 324, 53800, 500]
     */
    public ServerType(String[] strings) {
        this.name=strings[1];
        this.cores=Integer.parseInt(strings[2]);
        this.memory=Integer.parseInt(strings[3]);
        this.cost=Integer.parseInt(strings[4]);
        this.consumption=Integer.parseInt(strings[5]);
        this.ratio=1.0*cores/memory;
    }

    public int getCores() {
        return cores;
    }
    public int getMemory() {
        return memory;
    }

    public String getName() {
        return name;
    }

    public double getRatio() {
        return ratio;
    }

    @Override
    public int compareTo(ServerType o) {
        return Double.compare(ratio, o.getRatio());
    }

    public int getCost() {
        return cost;
    }

    public int getConsumption() {
        return consumption;
    }
}
